package com.woniuxy.producerconsumer.service.impl;

import com.woniuxy.pojo.Mail;
import com.woniuxy.producerconsumer.service.PCService;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PCServiceImpl implements PCService {

    @Autowired
    RabbitTemplate rabbitTemplate;

    @Override
    public void sendMail(String pcQueue, Mail mail) {
        //设置队列名称 可以不写
        rabbitTemplate.setDefaultReceiveQueue("PCQueue");
        //发送消息到空串交换机，和PCQueue的队列上
        rabbitTemplate.convertAndSend("","PCQueue",mail);
    }
}
